const {
  Sequelize,
  Model
} = require('sequelize')
const {
  sequelize
} = require('../config/db');

// 定义模型
class conversation extends Model {

}

conversation.init({
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  sender:{
    type: Sequelize.INTEGER(11),
    allowNull: false,
    comment: '发送者',
  },
  receiverName:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '接收者'
  },
  receiverId:{
    type: Sequelize.STRING,
    allowNull: false,
    comment: '接收者Id'
  },
  receiverSocketID:{
    type: Sequelize.STRING,
    allowNull: false,
    comment: '接收者SocketID'
  },
  receiverImg:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '接收者头像'
  },
  content:{
    type: Sequelize.STRING,
    allowNull: true,
    comment: '第一句话'
  },
}, {
  sequelize,
  modelName: 'conversation',
  tableName: 'conversation'
})

// conversation.sync({
//   force: true
// })

module.exports = conversation